#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 510, M = 1e5 + 10;
int n, m;
int d[N];
int temp[N];
int h[N], e[M], ne[M], idx;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

bool tuopu()
{
	queue<int>q;
	for (int i = 1; i <= n; i++) {
		if (!d[i])q.push(i);
	}
	int cnt = 0;
	while (q.size()) {
		int t = q.front();
		q.pop();
		cnt++;
		for (int i = h[t]; ~i; i = ne[i]) {
			int j = e[i];
			if (--d[j] == 0)q.push(j);
		}
	}
	return cnt == n;
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		d[b]++;
	}
	for (int i = 1; i <= n; i++)temp[i] = d[i];
	for (int i = 1; i <= n; i++) {
		if (d[i]) {
			d[i]--;
			if (tuopu()) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}